#pragma once

#define BUFFERSIZE 1024
#define LINE_FLUSH (0x00000001)
#define FULL_FLUSH (0x00000001<<1)
#define NO_FLUSH (0x00000001<<2)

typedef struct _MyFILE
{
    int fileno; // 文件描述符
    char* buffer;   // 输出缓冲区
    int cap;    // 缓冲区容量
    int pos;   // 缓冲区中已使用的大小
    int flush_mode; // 刷新策略
}_MyFILE;

_MyFILE* MyFopen(const char* pathname, const char* mode);
void MyFclose(_MyFILE* file);
int MyFwrite(_MyFILE* file, const void* str, unsigned size);
void DebugPrint(_MyFILE* file);
const char* toString(int code);
void MyFlush(_MyFILE *file);
